package com.gf.framework.rpcdemo.api.feign.fallback;

import com.gf.framework.common.result.BaseResultCodeEnum;
import com.gf.framework.common.result.R;
import com.gf.framework.rpcdemo.api.feign.IApi;

import com.gf.framework.rpcdemo.api.model.RequestModel;
import com.gf.framework.rpcdemo.api.model.ResponseModel;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author gaofei
 * @date 2022/6/3 18:01
 */
@Component
public class IApiFallback implements FallbackFactory<IApi> {
    @Override
    public IApi create(Throwable throwable) {
        return new IApi() {

            @Override
            public R<String> hello() {
                return R.fail(BaseResultCodeEnum.SYSTEM_ERROR);
            }

            @Override
            public R<ResponseModel> posttest(RequestModel requestModel) {
                return R.fail(BaseResultCodeEnum.SYSTEM_ERROR);
            }
        };
    }
}
